<template>
  <div>
    <el-row>
      <el-col :span="24">
        <el-form :inline="true" class="demo-form-inline">
          <el-form-item label="">
            <el-input
              size="medium"
              v-model="mLast"
              placeholder="查询"
            ></el-input>
          </el-form-item>
          <el-form-item>
            <el-button
              size="small"
              type="primary"
              icon="el-icon-search"
              @click="onSubmit"
              >查询</el-button
            >
          </el-form-item>
          <el-form-item>
            <el-button
              @click="addition(1)"
              size="small"
              type="success"
              icon="el-icon-circle-plus-outline"
              >新建</el-button
            >
          </el-form-item>
        </el-form>
      </el-col>
      <el-col :span="24">
        <div>
          <el-table :data="tableData" border style="width: 100%">
            <el-table-column type="expand">
              <template #default="props">
                <el-form label-position="left" inline class="demo-table-expand">
                  <el-form-item label="备注:">
                    <span>{{ props.row.beizhu }}</span>
                  </el-form-item>
                  <el-form-item label="">
                    <el-button type="warning" size="mini">下载</el-button>
                  </el-form-item>
                </el-form>
              </template>
            </el-table-column>
            <el-table-column label="ID" prop="id"> </el-table-column>
            <el-table-column label="类别" prop="name"> </el-table-column>
            <el-table-column label="签署日期" prop="desc"> </el-table-column>
            <el-table-column label="密级" prop="category"> </el-table-column>
            <el-table-column label="作者" prop="address"> </el-table-column>
            <el-table-column label="签署" prop="shop"> </el-table-column>
            <el-table-column label="文件名称" prop="shopId"> </el-table-column>
            <el-table-column label="序列号" prop="xulie"> </el-table-column>
            <el-table-column label="操作" width="320" align="center">
              <template #default="scope">
                <el-button size="mini" @click="arraycopy(scope.row)"
                  >复制序列号</el-button
                >

                <el-button
                  size="mini"
                  type="primary"
                  @click="editorPara(scope.row, 2)"
                  >编辑</el-button
                >
                <el-button
                  size="mini"
                  type="danger"
                  @click="deleted(scope.$index, scope.row)"
                  >封存</el-button
                >
                <el-button size="mini" type="danger">作废</el-button>
              </template>
            </el-table-column>
          </el-table>
        </div>
      </el-col>
    </el-row>
    <el-dialog
      :title="single"
      v-model="plassets"
      width="800px"
      :close-on-click-modal="false"
    >
      <!-- <el-tabs v-model="activeName" @tab-click="handleClick">
        <el-tab-pane label="模版1" name="first">

        </el-tab-pane>
        <el-tab-pane label="模版2" name="second">模版2</el-tab-pane>
        <el-tab-pane label="模版3" name="third">模版3</el-tab-pane>
        <el-tab-pane label="模版4" name="fourth">模版4</el-tab-pane>
      </el-tabs> -->
      <el-form ref="form" :model="form" label-width="80px">
        <el-form-item label="文档类型">
          <el-select
            style="width: 300px"
            v-model="form.simpleType"
            placeholder="请选择"
            clearable
          >
            <el-option
              v-for="item in datatype"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
          <el-button type="primary" icon="el-icon-plus" circle></el-button>
        </el-form-item>
      </el-form>
      <template #footer>
        <span class="dialog-footer">
          <el-button @click="plassets = false">取 消</el-button>
          <el-button type="primary" v-if="under == 1" @click="determine()"
            >确 定</el-button
          >
          <el-button @click="hardware()" v-else type="primary"
            >编辑 确 定</el-button
          >
        </span>
      </template>
    </el-dialog>
  </div>
</template>

<script>
// import { nation } from "../../api/data";
import { nation, security, signedCode } from "@/api/data";
// import sumtemplate from "./get_template.vue";
// import { security } from "@/api/data";
export default {
  // components: {
  //   sumtemplate,
  // },
  data() {
    return {
      tabPosition: "0",
      activeName: "second",
      fileList: [],
      category: "",
      mLast: "",
      plassets: false,
      under: 1,
      contract: false, //合同类型
      form: {
        simpleType: "",
      },
      datatype: [
        {
          value: "1",
          label: "合同",
        },
        {
          value: "2",
          label: "协议",
        },
        {
          value: "3",
          label: "方案",
        },
        {
          value: "4",
          label: "报告",
        },
        {
          value: "5",
          label: "行政公文",
        },
        {
          value: "6",
          label: "会议纪要",
        },
      ],
      manufacturers: "", //制造商
      accepted: [],
      single: "",
      headerObj: "", //上传图片请求头
      tableData: [
        {
          id: "12987122",
          name: "报价单",
          desc: "2021/5/25",
          category: "决策层",
          address: "方文平",
          shop: "董事长签署",
          shopId: "螺栓监测耗材报价单",
          xulie: "012N5DMF150R010",
          beizhu: "上海电气",
        },
      ],
      options: nation,
      value: "",
      software: security, //密级
      offset: "",
      authors: [], //作者
      getAuthors: "",
      signed: signedCode, //签署码
      decode: "",
    };
  },
  created() {
    let str = sessionStorage.getItem("token");
    // this.headerObj["Authorization"] = `Bearer ${str}`;
    this.headerObj = `Bearer ${str}`;
  },
  beforeMount() {
    this.author();
  },
  methods: {
    handleClick(tab, event) {
      console.log(tab, event);
    },
    onSubmit() {},
    arraycopy(row) {
      console.log(row);
      var Url2 = row.xulie; //每一行的某个值，如选中的当前行的url
      var oInput = document.createElement("input"); //创建一个隐藏input（重要！）
      oInput.value = Url2; //赋值
      console.log(oInput.value);
      document.body.appendChild(oInput);
      oInput.select(); // 选择对象
      document.execCommand("Copy"); // 执行浏览器复制命令
      oInput.className = "oInput";
      oInput.style.display = "none";
      // alert('复制成功');
      this.$notify({
        title: "成功",
        message: "复制成功",
        type: "success",
      });
    },
    determine() {
      console.log(this.getAuthors);
    },
    addition(index) {
      this.plassets = true;
      this.under = index;
    },
    disallow() {
      console.log(this.form.dates);
      this.form.dates = this.dateFormat(this.form.dates);
      console.log(this.form.dates);
    },
    //时间转换
    dateFormat(dateData) {
      var date = new Date(dateData);
      var y = date.getFullYear();
      var m = date.getMonth() + 1;
      m = m < 10 ? "0" + m : m;
      var d = date.getDate();
      d = d < 10 ? "0" + d : d;
      const time = y + "-" + m + "-" + d;
      return time;
    },
    author() {
      this.$axios
        .get(`api/serial/other/staff`, {
          headers: {
            Authorization: this.headerObj,
          },
        })
        .then((res) => {
          // console.log(res);
          let initData = res.data.data;
          console.log(initData);
          let trees = [];
          initData.forEach((item, index) => {
            trees[index] = {
              value: item.id,
              label: item.name,
            };
          });
          this.authors = trees;
        });
    },
    //上传
    handleRemove(file, fileList) {
      console.log(file, fileList);
    },
    handlePreview(file) {
      console.log(file);
    },
    handleExceed(files, fileList) {
      this.$message.warning(
        `当前限制选择 3 个文件，本次选择了 ${files.length} 个文件，共选择了 ${
          files.length + fileList.length
        } 个文件`
      );
    },
    beforeRemove(file) {
      return this.$confirm(`确定移除 ${file.name}？`);
    },
  },
};
</script>

<style scoped>
.addccc {
  margin-bottom: 20px;
}
.demo-table-expand {
  font-size: 0;
}
.demo-table-expand label {
  width: 90px;
  color: #99a9bf;
}
.demo-table-expand .el-form-item {
  margin-right: 0;
  margin-bottom: 0;
  width: 100%;
}
.balance {
  width: 200px;
  height: 100px;
  background-color: yellow;
}
</style>